package kr.hkit.powerjava.chapter22.work;

import java.util.ArrayList;
import java.util.StringTokenizer;

import javax.swing.JOptionPane;

public class TestMain {
	public static void main(String[] args) {
		ArrayList<Department> dptList = new ArrayList<>();
		DepartmentDao dptDao = new DepartmentDao();

		dptDao.addItem(new Department(1, "자바", 4));

		dptDao.prnList();

		/*
		 * ArrayList<Student> stdList = new ArrayList<>(); initList(stdList);
		 * StudentManager sm = new StudentManager(stdList); Student std = null;
		 * 
		 * int res = 0;
		 * 
		 * do { System.out.println("메뉴를 선택하시오"); try { res =
		 * Integer.parseInt(JOptionPane
		 * .showInputDialog("1.추가 2. 검색 3. 삭제 4. 수정 5. 출력 6. 종료")); } catch
		 * (NumberFormatException e) { res = 6; } switch (res) { case 1: std =
		 * inputStdInfo(true); sm.addStudent(std); break; case 2: std =
		 * inputStdInfo(false); sm.searchStudent(std); break; case 3: std =
		 * inputStdInfo(false); sm.delStudent(std); break; case 4: std =
		 * inputStdInfo(true); sm.rewrite(std); break; case 5: sm.prnList();
		 * break; case 6: res = 6; break; }
		 * 
		 * } while (res != 6);
		 */

	}

	private static void prnList(ArrayList<Student> stdList) {
		// prnHeader();
		for (Student std : stdList) {
			System.out.println(std);
		}
	}

	private static void initList(ArrayList<Student> stdList) {
		stdList.add(new Student(1, "김태희", 87, 87, 87));
		stdList.add(new Student(2, "이민정", 76, 98, 82));
		stdList.add(new Student(3, "소유", 99, 78, 88));
		stdList.add(new Student(4, "유인나", 85, 97, 87));
		stdList.add(new Student(5, "황정음", 88, 84, 86));
	}

	private static Student inputStdInfo(boolean gubun) {
		if (gubun) {
			String std = JOptionPane.showInputDialog("학생번호 성명 국어 영어 수학");
			StringTokenizer st = new StringTokenizer(std);
			int stdNum = Integer.parseInt(st.nextToken());
			String stdName = st.nextToken();
			int kor = Integer.parseInt(st.nextToken());
			int eng = Integer.parseInt(st.nextToken());
			int math = Integer.parseInt(st.nextToken());
			return new Student(stdNum, stdName, kor, eng, math);
		} else {
			String std = JOptionPane.showInputDialog("학생번호 성명");
			StringTokenizer st = new StringTokenizer(std);
			int stdNum = Integer.parseInt(st.nextToken());
			String stdName = st.nextToken();
			return new Student(stdNum, stdName);
		}
	}

}
